﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.ComponentModel;

using Willson.JsbManager.Idal;
using Willson.JsbManager.Entity;
using Willson.JsbManager.BllEntity;
using Willson.JsbManager.Comm;

namespace Willson.JsbManager.Bll
{
    public class BLLJhBeginReg:BaseBLL
    {
        private ITableXtSbJd xt_sb_jd_DAL = null;

        public BLLJhBeginReg()
        {
            xt_sb_jd_DAL = Reflect<ITableXtSbJd>.Create("DAL_table_xt_sb_jd", "Willson.JsbManager.Dal"); 
        }

        public bool SaveJhBegin(int id,int begin)
        {
            Hashtable hash = new Hashtable();
            hash.Add("jd_jh_begin",begin);

            return xt_sb_jd_DAL.Update(id, hash);    
        }

        public BindingList<BEJhBeginRegInfo> GetList(int company_id)
        {
            BindingList<BEJhBeginRegInfo> list = new BindingList<BEJhBeginRegInfo>();

            Hashtable hash = new Hashtable();

            hash.Add("company_id",company_id);

            IEnumerator<TableXtSbJdEntity> ator = xt_sb_jd_DAL.Find(hash, SqlOperator.And, true).GetEnumerator();

            while (ator.MoveNext())
            {
                BEJhBeginRegInfo info = new BEJhBeginRegInfo();

                info.Id = ator.Current.Id;
                info.Jd_jh = ator.Current.Jd_jh;
                info.Jd_jh_begin = ator.Current.Jd_jh_begin;
                info.Jd_sum = ator.Current.Jd_sum;
                info.Sb_jd = ator.Current.Sb_jd;
                info.Sb_year = ator.Current.Sb_year;

                list.Add(info);
            }

            return list;
        }
    }
}
